<?php

namespace App\Http\Controllers\Home;

use Illuminate\Http\Request;

use App\Http\Requests;
use App\Http\Controllers\Controller;
use DB;
class Pccontroller extends Controller
{




	//显示简历
    public function getIndex()
    {

      // session(['stop'=>1]);
      // dd(session('stop'));
    	$id=session("user")['id'];
        $id=41;
    	$data=DB::table('interviewee')->where('id',$id)->get();     
    	$data1=DB::table('resume')->where('inter_id',$id)->get();
    	//期望行业/原职业
    	
    	$data1[0]->DesiredIndustry=DB::table('industrycate')->select('name')->where('id',$data1[0]->DesiredIndustry)->first()->name;
    	$data1[0]->CompanyIndustry=DB::table('industrycate')->select('name')->where('id',$data1[0]->CompanyIndustry)->first()->name;
    	
    	//期望职业
    	$data1[0]->desired_Jobtype_id=DB::table('cate')->select('name')->where('id',$data1[0]->desired_Jobtype_id)->first()->name;
    	//期望城市
    	$data1[0]->DesiredCity=DB::table('regioncate')->select('name')->where('id',$data1[0]->DesiredCity)->first()->name;
    	//期望工资、原工资
    	$data1[0]->DesiredSalaryScope=DB::table('pms')->select('value')->where('id',$data1[0]->DesiredSalaryScope)->first()->value;
    	$data1[0]->Salary=DB::table('pms')->select('value')->where('id',$data1[0]->Salary)->first()->value;
    	//现阶段状态
    	$data1[0]->CurrentCareerStatus=DB::table('resume_status')->select('value')->where('id',$data1[0]->CurrentCareerStatus)->first()->value;
    	//专本
    	$data1[0]->EducationLevel=DB::table('er')->select('value')->where('id',$data1[0]->EducationLevel)->first()->value;




    	//简历编辑时间
    	$data1[0]->time=date("Y-m-d H:i:s");




    	// dd($data1[0]);
    	

    	
    	return view('/home/pc/index',['data'=>$data[0],'data1'=>$data1[0]]);
    }

    //弹出留言板
    public function getBlock()
    {

    	return view('/home/pc/liu');
    }


    //留言板提交
    public function postLiu(Request $request)
    {
    	$data=$request->except('_token','feed','companyID','info','expectReplyType');
    	$data['time']=time();
        
    	$res=DB::table('liuyan')->insert($data);
    	if($res)
    	{
    		return view('/home/pc/sucess');
    	}
    }


   //修改简历
   public function getReset()
   {




   	         $re=DB::table('regioncate')->where('status',1)->take(28)->get();
             $sheng=DB::table('regioncate')->where('pid',0)->where('status',0)->get();
             // 职位表
             $tou=DB::table('industrycate')->where('pid',0)->get();
             
             foreach($tou as $k=>$v)
             {
               $erji[$k]=DB::table('industrycate')->where('pid',$v->id)->get();
             }
             //工资
             $salary=DB::table('pms')->get();
             //从事职业
             $zong=DB::table('cate')->where('pid',0)->get();
             foreach($zong as $k=>$v)
             {
                //计算高度
                $zong[$k]->length=DB::table('cate')->where('pid',$v->id)->count()*30.86;
             }
             
             $er=DB::table('cate')->where('pid','>',0)->where('pid','<',14)->get();

             $enducate=DB::table('er')->get();

             $status=DB::table('resume_status')->get();
    
             //默认值
         $id=session("user")['id'];
        
    	$data=DB::table('interviewee')->where('id',$id)->get();     
    	$data1=DB::table('resume')->where('inter_id',$id)->get();
    	//期望行业/原职业
    	
    	$data1[0]->DesiredIndustry=DB::table('industrycate')->select('name')->where('id',$data1[0]->DesiredIndustry)->first()->name;
    	$data1[0]->CompanyIndustry=DB::table('industrycate')->select('name')->where('id',$data1[0]->CompanyIndustry)->first()->name;
    	
    	//期望职业
    	$data1[0]->desired_Jobtype_id=DB::table('cate')->select('name')->where('id',$data1[0]->desired_Jobtype_id)->first()->name;
    	//期望城市
    	$data1[0]->DesiredCity=DB::table('regioncate')->select('name')->where('id',$data1[0]->DesiredCity)->first()->name;
    	//期望工资、原工资
    	$data1[0]->DesiredSalaryScope=DB::table('pms')->select('value')->where('id',$data1[0]->DesiredSalaryScope)->first()->value;
    	$data1[0]->Salary=DB::table('pms')->select('value')->where('id',$data1[0]->Salary)->first()->value;
    	//现阶段状态
    	$data1[0]->CurrentCareerStatus=DB::table('resume_status')->select('value')->where('id',$data1[0]->CurrentCareerStatus)->first()->value;
    	//专本
    	$data1[0]->EducationLevel=DB::table('er')->select('value')->where('id',$data1[0]->EducationLevel)->first()->value;




    	//简历编辑时间
    	$data1[0]->time=date("Y-m-d H:i:s");




    	// dd($data1[0]);
             return view('/home/pc/reset',['re'=>$re,'sheng'=>$sheng,'tou'=>$tou,'erji'=>$erji,'salary'=>$salary ,'zong'=>$zong,'er'=>$er,'enducate'=>$enducate,'status'=>$status,'data'=>$data[0],'data1'=>$data1[0]]);
  
   }


   //企业回馈
   public function getQiye()
   {

   	$data=DB::table('friendlink')->get();
   	return view('/home/pc/qiye',['data'=>$data]);
   }
   //ajax请求简历状态
   public function postAjaxjl(Request $request)
   {
   	$id=$request->id;
   	//rr=resume_recruit关联表 re=recruit企业职位  en=enterprises企业
   	if($id!=1)
   	{

		$data=DB::table('resume_recruit as rr')
		   	    ->leftJoin('recruit as re','rec_id','=','re.id')
		   	    ->leftJoin('enterprises as en','ent_id','=','en.id')
		   	    ->leftJoin('resume','res_id','=','resume.id')
		   	    ->leftJoin('regioncate','re.r_id','=','regioncate.id')//工作地点
		   	    ->leftJoin('pms','re.pms_id','=','pms.id')//工作年薪
		   	    ->select('rr.*','en.compname','re.workname','regioncate.name','resume.time','pms.value')
		   	    ->where('rr.status',$id)
		   	    ->get();
		   	 foreach($data as $k=>$v)
		   	 {
		   	 	$v->time=date("Y-m-d H:i:s ",$v->time);
		   	 }


		   	 return  response()->json($data);	
   	}else
   	{

   	 $data=DB::table('resume_recruit as rr')
		   	    ->leftJoin('recruit as re','rec_id','=','re.id')
		   	    ->leftJoin('enterprises as en','ent_id','=','en.id')
		   	    ->leftJoin('resume','res_id','=','resume.id')
		   	    ->leftJoin('regioncate','re.r_id','=','regioncate.id')//工作地点
		   	    ->leftJoin('pms','re.pms_id','=','pms.id')//工作年薪
		   	    ->select('rr.*','en.compname','re.workname','regioncate.name','resume.time','pms.value')
		   	    ->where('rr.status','<>',0)
		   	    ->get();
		   	 foreach($data as $k=>$v)
		   	 {
		   	 	$v->time=date("Y-m-d H:i:s ",$v->time);
		   	 }


		   	 return  response()->json($data);	


    }
   	}



}
